package com.manong.controller;

import com.manong.entity.AttendanceManagement;
import com.manong.entity.LeaveAnagement;
import com.manong.service.AttendanceManagementService;
import com.manong.service.LeaveAnagementService;
import com.manong.utils.Result;
import com.manong.vo.CommonReqVo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController//使用该注解，使得每个方法的返回值都会以json或xml的形式直接导入http响应体中
@RequestMapping("/api/leave-anagement")
@RequiredArgsConstructor
public class LeaveAnagementController {

    private final LeaveAnagementService leaveAnagementService;


    @PostMapping("/list")
    public Result list(@RequestBody CommonReqVo commonReqVo) {
        return Result.ok(leaveAnagementService.listAll(commonReqVo)).message("请假管理信息查询成功");
    }

    @PostMapping("/save")
    public Result save(@RequestBody LeaveAnagement leaveAnagement) {
        return Result.ok(leaveAnagementService.save1(leaveAnagement)).message("请假管理信息更新成功");
    }

    @PostMapping("/delete")
    public Result delete(@RequestBody CommonReqVo commonReqVo) {
        return Result.ok(leaveAnagementService.delete1(commonReqVo)).message("请假管理信息删除成功");
    }
    @PostMapping("/approve")
    public Result approve(@RequestBody CommonReqVo commonReqVo) {
        return Result.ok(leaveAnagementService.approve(commonReqVo)).message("请假管理信息审批成功");
    }

}
